﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LuKou.Shopspace.Domains;
using LuKou.Web.BLL.Extensions;
using LuKou.Shopspace.Services;

namespace LuKou.Web.BLL.Service
{
    public class ShopGiftServices
    {
        static IShopGiftSvr _svr;
        static ShopGiftServices()
        {
            _svr = ServiceHelper.Get<IShopGiftSvr>("IShopGiftSvr");
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public static PagedList<ShopGift> GetShopGiftList(int? state, int index, int pageSize, string orderField)
        {
            if (index < 1) index = 1;
            if (pageSize < 1) pageSize = 1;
            ShopGiftQueryParam param = new ShopGiftQueryParam();
            if (state.HasValue)
            {
                param.AddParamOfDataState(state.GetValueOrDefault());
            }
            if (!string.IsNullOrEmpty(orderField))
            {
                param.SetOrderByField(orderField);
            }
            IList<ShopGift> result = _svr.GetShopGiftList(null, true, pageSize * (index - 1), pageSize).Cast<ShopGift>().ToList();
            return new PagedList<ShopGift>(result, index, pageSize, _svr.GetShopGiftCount(null));
        }
    }
}
